package com.ksm.zyz.common.base;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * 抽象实现类
 * @author liuhao
 *
 * @param <T>
 * @param <E>
 */
@Service("baseService")
public abstract class BaseServiceImpl<T> implements BaseService<T> {

	/**
	 * 抽象方法
	 * @return
	 */
	@Autowired
	protected BaseMapper<T> baseMapper;
	/*protected abstract BaseMapper<T> getBaseMapper();*/

	@CacheEvict(value = "selectAll",allEntries = true)
	public int save(T obj) {
		// TODO Auto-generated method stub
		return baseMapper.save(obj);
	}
   
	public int delete(String[] ids) {
		// TODO Auto-generated method stub
		return baseMapper.delete(ids);
	}

	@CacheEvict(value = "selectAll",allEntries = true)
	public int change(Map<String,Object> map){
		return baseMapper.change(map);
	}

	@CacheEvict(value = "selectAll",allEntries = true)
	public int update(T obj) {
		// TODO Auto-generated method stub
		return baseMapper.update(obj);
	}

	public T selectById(String id) {
        // TODO Auto-generated method stub
        return (T) baseMapper.selectById(id);
    }

	@Cacheable(value = "selectAll")
	public List<T> selectByFields(T obj) {
		// TODO Auto-generated method stub
		return baseMapper.selectByFields(obj);
	}
	
	@Override
	public List<T> selectAllList() {
		// TODO Auto-generated method stub
		return baseMapper.selectAllList();
	}
	
	@Cacheable(value = "selectAll")
	public List<T> selectAll(T obj) {
		// TODO Auto-generated method stub
		return baseMapper.selectAll(obj);
	}

	public Integer sysselectCount(T obj){
		return baseMapper.sysselectCount(obj);
	}
	
	public Integer selectCount(int i){
		return baseMapper.selectCount(i);
	}
	@Override
	public int insertSelective(T obj) {		
		return baseMapper.insertSelective(obj);
	}

	@Override
	public int insert(T obj) {
		return baseMapper.insert(obj);
	}
	 public List<T> selectAllNew(int ustate){
		 return baseMapper.selectAllNew(ustate);
	 }
	 /**
		 * 删除总数据库中的数据
		 * @param ids
		 */
     public int deleteInfo(T obj)
     {
    	 return baseMapper.deleteInfo(obj);
     }
     
     public int updateInfo(T obj) {
		return baseMapper.updateInfo(obj);
	}
     /**
		 * 查询对象
		 * @param obj
		 */
  public T selectInfo(T obj){
	  return baseMapper.selectInfo(obj);
  }
     /**
		 * 修改sqlserver数据库中的状态
		 * @param 
		 */
    public int updateState(int state){
    	return baseMapper.updateState(state);
    }
    /**
   	 * 查看表中有无数据
   	 * @param 
   	 */
     public  int selectInfoCount(T obj)
     {
    	 return baseMapper.selectInfoCount(obj);
     }
     /**20170416
 	 * 查看总数据库中一个超市未同步的数据
 	 * @param 
 	 */
     public List<T> selectSmIdnew(T obj)
     {
    	 return baseMapper.selectSmIdnew(obj);
     }
     /**20170416
   	 * 修改总数据库中一个超市未同步的数据的状态改为已经同步
   	 * @param 
   	 */
      public List<T> selectSmIdnewstate(T obj)
      {
    	  return baseMapper.selectSmIdnewstate(obj);
      }
}
     
